package com.youbug.custservice.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.youbug.common.config.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

/**
 * <p>
 * 消息表
 * </p>
 *
 * @author youbug
 * @since 2023-01-07
 */
@Data
@EqualsAndHashCode(callSuper = true)
@ApiModel(value="Message对象", description="消息表")
@Document(indexName = "kefu-message")
public class Message extends BaseEntity {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "主键")
    @TableId(value = "id", type = IdType.AUTO)
    @Field(type = FieldType.Long)
    private Long id;

    @ApiModelProperty(value = "会话表主键")
    @Field(name = "chat_id", type = FieldType.Long)
    private Long chatId;

    @ApiModelProperty(value = "消息类型 text，image，audio，radio, json")
    @Field(type = FieldType.Keyword)
    private String type;

    @ApiModelProperty(value = "消息内容")
    @Field(type = FieldType.Text)
    private String content;

    @ApiModelProperty(value = "发送方agent，client")
    @Field(type = FieldType.Keyword)
    private String sender;

    @ApiModelProperty(value = "发送方id")
    @Field(name = "sender_id", type = FieldType.Long)
    private Long senderId;

    @ApiModelProperty(value = "发送方名")
    @Field(name = "sender_name", type = FieldType.Keyword)
    private String senderName;
    
    @TableField(exist = false)
    private String analyzer;

    public Message() {
    }

    public Message(String sender,String type, String content) {
        this.sender = sender;
        this.type = type;
        this.content = content;
    }
}
